using System;
using System.Collections.Generic;
using System.Text;
using Lizk.SimpleHUD;

namespace SharpMedia.Controls
{
    /// <summary>
    /// This simple container class ensures a contained object is centered at all times.
    /// </summary>


    public class HUDCentering : HUDContainerSimple
    {
        HUDControl item;
        public HUDCentering(HUDControl parent, HUDControl item)
        {
            this.item = item;
            itemSize = item.Size;
            this.Size = parent.Size;
            this.Anchor = Anchor.All;
            this.Add(item);
        }

        SizeS itemSize;

        public override void Update(TimeSpan ts)
        {
            base.Update(ts);
            if (itemSize != item.Size)
            {
                item.Location = new PointS((Bounds.Width - item.Size.Width) / 2f, (Bounds.Height - item.Bounds.Height) / 2f);
                itemSize = item.Size;
            }
        }

        public override void ResizeMove(RectangleS oldRect, RectangleS newRect)
        {
            base.ResizeMove(oldRect, newRect);
            item.Location = new PointS((Bounds.Width - item.Size.Width) / 2f, (Bounds.Height - item.Bounds.Height) / 2f);
        }
    

    }
}
